import { request } from "@/utils/request";
import type {
  DeleteParams,
  DeleteValueParams,
  QueryParams,
  QueryResult,
  QueryValueListParams,
  QueryValueParams,
  QueryValueResult,
  ValueParams,
  ValueSetParams,
} from "./typing";
import type { PageResult, ResponseBody } from "@/api/typing";

/**新增值集 */
export const add = (params: ValueSetParams) => {
  return request.post<ValueSetParams, ResponseBody>("/value-set/add", params);
};

/**修改值集 */
export const update = (params: ValueSetParams) => {
  return request.put<ValueSetParams, ResponseBody>("/value-set/update", params);
};

/**分页查询值集 */
export const queryByPage = (params: QueryParams) => {
  return request.get<QueryParams, ResponseBody<PageResult<QueryResult>>>(
    "/value-set/page",
    { params }
  );
};

/**删除值集 */
export const del = (params: DeleteParams) => {
  return request.delete<DeleteParams, ResponseBody>("/value-set/delete", {
    params,
  });
};

/**新增值集值 */
export const addValue = (params: ValueParams) => {
  return request.post<ValueParams, ResponseBody>(
    "/value-set/value/add",
    params
  );
};

/**修改值集值 */
export const updateValue = (params: ValueParams) => {
  return request.put<ValueParams, ResponseBody>(
    "/value-set/value/update",
    params
  );
};

/**列表查询值集值 */
export const queryValueByList = (params: QueryValueParams) => {
  return request.get<QueryValueParams, ResponseBody<QueryValueResult[]>>(
    "/value-set/value/list",
    { params }
  );
};

/**删除值集值 */
export const delValue = (params: DeleteValueParams) => {
  return request.delete<DeleteValueParams, ResponseBody>(
    "/value-set/value/delete",
    { params }
  );
};

/**根据值集编码查询值列表 */
export const queryValueListByCode = (params: QueryValueListParams) => {
  return request.get<QueryValueListParams, ResponseBody<QueryValueResult[]>>(
    "/value-set/value/list/code",
    { params }
  );
};
